#ifndef TPUBLICMGR_H
#define TPUBLICMGR_H

#include "../../include/itpublicmgr.h"

struct TTmPublic
{
    QString         name;
    unsigned long   ulPublicId;
    long            lLoadOrder;
    long            lUnloadOrder;
    QString         strDllPath;
    void            *pMgr;
    QLibrary        *pDll;
};

typedef std::list<TTmPublic*> TTmPublicList;

struct TTmModel
{
    TTmModel() {memset(this,0,sizeof(TTmModel));}
    long        lPublicId;
    ITModelBase *pModel;
};

typedef std::map<unsigned long, TTmModel*> TTmModelMap;

class ITLogger;
class TPublicMgr : public ITPublicMgr
{
public:
    static TPublicMgr* GetInstance() {static TPublicMgr __instance; return &__instance;}
public:
    virtual TRESULT Init();
    virtual TRESULT UnInit();
    virtual TRESULT SetFramework(ITFramework *pFrm);
    virtual TRESULT GetPublicFromId(unsigned long ulModelId, ITModelBase **ppModel);
    virtual TRESULT Find(unsigned long ulModelId, ITModelBase **ppModel);
public:
    TPublicMgr();
    virtual ~TPublicMgr();
private:
    ITFramework     *m_pFramework;
    TTmPublicList   m_pPublicList;
    TTmModelMap     m_pModelMap;
    QString         m_szLog;
    ITLogger        *m_pLogger;
};

#endif // TPUBLICMGR_H
